Telegram Group & Telegram Channel
Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation and special characters).

Use isalnum() to filter out non-alphanumeric characters, lower() to transform each character to lowercase.

Use collections.Counter to count the resulting characters for each string and compare the results.

Code
:

from collections import Counter

def is_anagram(s1, s2):
return Counter(
c.lower() for c in s1 if c.isalnum()
) == Counter(
c.lower() for c in s2 if c.isalnum()
)

EXAMPLE

is_anagram("#anagram", "Nag a ram!")

Output:
True

Share and Support
@Python_Codes



tg-me.com/python_codes/150
Create:
Last Update:

Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation and special characters).

Use isalnum() to filter out non-alphanumeric characters, lower() to transform each character to lowercase.

Use collections.Counter to count the resulting characters for each string and compare the results.

Code
:

from collections import Counter

def is_anagram(s1, s2):
return Counter(
c.lower() for c in s1 if c.isalnum()
) == Counter(
c.lower() for c in s2 if c.isalnum()
)

EXAMPLE

is_anagram("#anagram", "Nag a ram!")

Output:
True

Share and Support
@Python_Codes

BY Python Codes


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/python_codes/150

View MORE
Open in Telegram


Python Codes Telegram | DID YOU KNOW?

Date: |

Newly uncovered hack campaign in Telegram

The campaign, which security firm Check Point has named Rampant Kitten, comprises two main components, one for Windows and the other for Android. Rampant Kitten’s objective is to steal Telegram messages, passwords, and two-factor authentication codes sent by SMS and then also take screenshots and record sounds within earshot of an infected phone, the researchers said in a post published on Friday.

The messaging service and social-media platform owes creditors roughly $700 million by the end of April, according to people briefed on the company’s plans and loan documents viewed by The Wall Street Journal. At the same time, Telegram Group Inc. must cover rising equipment and bandwidth expenses because of its rapid growth, despite going years without attempting to generate revenue.

Python Codes from br


Telegram Python Codes
FROM USA